﻿@model ShopModel

<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-form" wid100 lay-filter="">
            <input asp-for="Id" type="hidden" />
            <input asp-for="Published" type="hidden" />
            <input asp-for="Code" type="hidden" />
            <div class="layui-form-item">
                <div class="col-md-3">
                    <label class="layui-form-label">名称</label>
                </div>
                <div class="layui-input-inline">
                    <u-editor asp-for="Name" />
                    <span asp-validation-for="Name"></span>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="col-md-3">
                    <label class="layui-form-label">地址</label>
                </div>
                <div class="layui-input-inline">
                    <u-editor asp-for="Remark" />
                    <span asp-validation-for="Remark"></span>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="col-md-3">
                    <label class="layui-form-label">纬度</label>
                </div>
                <div class="layui-input-inline">
                    <input asp-for="Latitude" asp-format="{0:F6}" class="layui-input" />
                    <span asp-validation-for="Latitude"></span>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="col-md-3">
                    <label class="layui-form-label">经度</label>
                </div>
                <div class="layui-input-inline">
                    <input asp-for="Longitude" asp-format="{0:F6}" class="layui-input" />
                    <span asp-validation-for="Longitude"></span>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="col-md-3">
                    <label class="layui-form-label">营业时间</label>
                </div>
                <div class="layui-input-inline">
                    <u-editor asp-for="OpeningHours"  />
                    <span asp-validation-for="OpeningHours"></span>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button id="layuiadmin-app-form-submit" style="display:none" class="layui-btn" lay-submit lay-filter="btn_confirm_save">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</div>


<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set'], function () {
        var $ = layui.$
            , form = layui.form
            ,active = { }
            form.on('submit(btn_confirm_save)', function (obj) {
                var index = layer.load(2, { shade: false });
              var field = obj.field; //获取提交的字段
                //layer.msg(JSON.stringify(obj.field));
                //提交 Ajax 成功后，关闭当前弹层并重载表格
                $.post('@Url.Action("Edit")', field, function (rep) {
                    if (rep.success == 1) {
                        layer.close(index);
                        layer.msg("保存成功,即将自动关闭", { time: 2 * 1000 }, function () {
                            var iframe_index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            console.log("当前iframe层的索引:" + iframe_index + "==window.name:" + window.name);
                            parent.layer.close(iframe_index); //再执行关闭
                            window.parent.location.reload();
                        });
                    }
                });
                return false;
        });
        $('.layui-btn.layuiadmin-btn-tags').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script>